<!DOCTYPE html>
<html>
  <head>
  <meta charset='UTF-8'>
  <title>CamanJS Documentation</title>
  <link rel='stylesheet' href='../../assets/codo.css' type='text/css'>
  <script src='../../assets/codo.js'></script>
  <script src='../../assets/search_data.js'></script>
</head>
  <body>
    <div id='base' data-path='../../'></div>
<div id='header'>
  <div id='menu'>
    <a href='../../README.md.html' title='CamanJS'>CamanJS</a>
    &raquo;
    <a href='../../class_index.html' title='Index'>Index</a>
    &raquo;
    <a href='../../classes/Caman.html' title='Caman'>Caman</a>
    &raquo;
    <span class='title'>Calculate</span>
    <nav>
      <ul>
        <li class='noframes'>
          (<a class='noframes' href='#'>no frames</a>)
        </li>
      </ul>
    </nav>
    <div id='search'>
      <a id='class_list_link' href='../../class_list.html'>Classes</a>
      <a id='file_list_link' href='../../file_list.html'>Files</a>
      <a id='method_list_link' href='../../method_list.html'>Methods</a>
      <a id='extra_list_link' href='../../extra_list.html'>Extras</a>
    </div>
  </div>
  <iframe id='search_frame'></iframe>
  <div id='fuzzySearch'>
    <input type='text'>
    <ol></ol>
  </div>
  <div id='help'>
    <p>
      Quickly fuzzy find classes, mixins, methods, file:
    </p>
    <ul>
      <li>
        <span>Ctrl-T</span>
        Open fuzzy finder dialog
      </li>
    </ul>
    <p>
      In frame mode you can toggle the list naviation frame on the left side:
    </p>
    <ul>
      <li>
        <span>Ctrl-L</span>
        Toggle list view
      </li>
    </ul>
    <p>
      You can focus a list in frame mode or toggle a tab in frameless mode:
    </p>
    <ul>
      <li>
        <span>Ctrl-C</span>
        Class list
      </li>
      <li>
        <span>Ctrl-I</span>
        Mixin list
      </li>
      <li>
        <span>Ctrl-F</span>
        File list
      </li>
      <li>
        <span>Ctrl-M</span>
        Method list
      </li>
      <li>
        <span>Ctrl-E</span>
        Extras list
      </li>
    </ul>
    <p>
      You can focus and blur the search input:
    </p>
    <ul>
      <li>
        <span>Ctrl-S</span>
        Focus search input
      </li>
      <li>
        <span>Esc</span>
        Blur search input
      </li>
    </ul>
    <p>
      In frameless mode you can close the list tab:
    </p>
    <ul>
      <li>
        <span>Esc</span>
        Close list tab
      </li>
    </ul>
  </div>
</div>
    <div id='content'>
      <h1>
        Class:
        Caman.Calculate
      </h1>
      <table class='box'>
        <tr>
          <td>Defined in:</td>
          <td>src&#47;core&#47;calculate.coffee</td>
        </tr>
      </table>
      <h2>Overview</h2>
      <div class='docstring'>
  <p>Various math-heavy helpers that are used throughout CamanJS.</p>
</div>
<div class='tags'>
</div>
      <h2>Class Method Summary</h2>
      <ul class='summary'>
  <li>
    <span class='signature'>
      <a href='#distance-class'>
        + (Number) <strong>distance</strong>(x1, y1, x2, y2)
      </a>
    </span>
    <span class='desc'>
      
    </span>
  </li>
  <li>
    <span class='signature'>
      <a href='#randomRange-class'>
        + (Number) <strong>randomRange</strong>(min, max, getFloat = false)
      </a>
    </span>
    <span class='desc'>
      
    </span>
  </li>
  <li>
    <span class='signature'>
      <a href='#luminance-class'>
        + (Number) <strong>luminance</strong>(rgba)
      </a>
    </span>
    <span class='desc'>
      Calculates the luminance of a single pixel using a special weighted sum.
    </span>
  </li>
  <li>
    <span class='signature'>
      <a href='#bezier-class'>
        + (Array) <strong>bezier</strong>(start, ctrl1, ctrl2, end, lowBound = 0, highBound = 255)
      </a>
    </span>
    <span class='desc'>
      Generates a bezier curve given a start and end point, with control points in between.
    </span>
  </li>
  <li>
    <span class='signature'>
      <a href='#hermite-class'>
        + (Array) <strong>hermite</strong>(controlPoints, lowBound, highBound)
      </a>
    </span>
    <span class='desc'>
      Generates a hermite curve given a start and end point, with control points in between.
    </span>
  </li>
  <li>
    <span class='signature'>
      <a href='#missingValues-class'>
        + (Array) <strong>missingValues</strong>(values, endX)
      </a>
    </span>
    <span class='desc'>
      Calculates possible missing values from a given value array.
    </span>
  </li>
</ul>
      <h2>Class Method Details</h2>
      <div class='methods'>
  <div class='method_details'>
    <p class='signature' id='distance-class'>
      + (Number) <strong>distance</strong>(x1, y1, x2, y2)
    </p>
    <div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>x1</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>1st point x-coordinate.</span>
    </li>
    <li>
      <span class='name'>y1</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>1st point y-coordinate.</span>
    </li>
    <li>
      <span class='name'>x2</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>2nd point x-coordinate.</span>
    </li>
    <li>
      <span class='name'>y2</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>2nd point y-coordinate.</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Number</tt>)
      &mdash;
      <span class='desc'>The distance between the two points.</span>
    </li>
  </ul>
</div>
  </div>
  <div class='method_details'>
    <p class='signature' id='randomRange-class'>
      + (Number) <strong>randomRange</strong>(min, max, getFloat = false)
    </p>
    <div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>min</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>The lower bound (inclusive).</span>
    </li>
    <li>
      <span class='name'>max</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>The upper bound (inclusive).</span>
    </li>
    <li>
      <span class='name'>getFloat</span>
      <span class='type'>
        (<tt>Boolean</tt>)
      </span>
      &mdash;
      <span class='desc'>Return a Float or a rounded Integer?</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Number</tt>)
      &mdash;
      <span class='desc'>The pseudorandom number, either as a float or integer.</span>
    </li>
  </ul>
</div>
  </div>
  <div class='method_details'>
    <p class='signature' id='luminance-class'>
      + (Number) <strong>luminance</strong>(rgba)
    </p>
    <div class='docstring'>
  <p>Calculates the luminance of a single pixel using a special weighted sum.</p>
</div>
<div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>rgba</span>
      <span class='type'>
        (<tt>Object</tt>)
      </span>
      &mdash;
      <span class='desc'>RGBA object describing a single pixel.</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Number</tt>)
      &mdash;
      <span class='desc'>The luminance value of the pixel.</span>
    </li>
  </ul>
</div>
  </div>
  <div class='method_details'>
    <p class='signature' id='bezier-class'>
      + (Array) <strong>bezier</strong>(start, ctrl1, ctrl2, end, lowBound = 0, highBound = 255)
    </p>
    <div class='docstring'>
  <p>Generates a bezier curve given a start and end point, with control points in between.
Can also optionally bound the y values between a low and high bound.</p><p>This is different than most bezier curve functions because it attempts to construct it in such 
a way that we can use it more like a simple input -&gt; output system, or a one-to-one function. 
In other words we can provide an input color value, and immediately receive an output modified 
color value.</p><p>Note that, by design, this does not force X values to be in the range [0..255]. This is to
generalize the function a bit more. If you give it a starting X value that isn&#39;t 0, and/or a
ending X value that isn&#39;t 255, you may run into problems with your filter!</p>
</div>
<div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>2-item</span>
      <span class='type'>
        (<tt>Array</tt>)
      </span>
      &mdash;
      <span class='desc'>arrays describing the x, y coordinates of the control points. Minimum two.</span>
    </li>
    <li>
      <span class='name'>lowBound</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>(optional) Minimum possible value for any y-value in the curve.</span>
    </li>
    <li>
      <span class='name'>highBound</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>(optional) Maximum posisble value for any y-value in the curve.</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Array</tt>)
      &mdash;
      <span class='desc'>Array whose index represents every x-value between start and end, and value represents the corresponding y-value.</span>
    </li>
  </ul>
</div>
  </div>
  <div class='method_details'>
    <p class='signature' id='hermite-class'>
      + (Array) <strong>hermite</strong>(controlPoints, lowBound, highBound)
    </p>
    <div class='docstring'>
  <p>Generates a hermite curve given a start and end point, with control points in between.
Can also optionally bound the y values between a low and high bound.</p><p>This is different than most hermite curve functions because it attempts to construct it in such 
a way that we can use it more like a simple input -&gt; output system, or a one-to-one function. 
In other words we can provide an input color value, and immediately receive an output modified 
color value.</p><p>Note that, by design, this does not force X values to be in the range [0..255]. This is to
generalize the function a bit more. If you give it a starting X value that isn&#39;t 0, and/or a
ending X value that isn&#39;t 255, you may run into problems with your filter!</p>
</div>
<div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>2-item</span>
      <span class='type'>
        (<tt>Array</tt>)
      </span>
      &mdash;
      <span class='desc'>arrays describing the x, y coordinates of the control points. Minimum two.</span>
    </li>
    <li>
      <span class='name'>lowBound</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>(optional) Minimum possible value for any y-value in the curve.</span>
    </li>
    <li>
      <span class='name'>highBound</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>(optional) Maximum possible value for any y-value in the curve.</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Array</tt>)
      &mdash;
      <span class='desc'>Array whose index represents every x-value between start and end, and value represents the corresponding y-value.</span>
    </li>
  </ul>
</div>
  </div>
  <div class='method_details'>
    <p class='signature' id='missingValues-class'>
      + (Array) <strong>missingValues</strong>(values, endX)
    </p>
    <div class='docstring'>
  <p>Calculates possible missing values from a given value array. Note that this returns a copy
and does not mutate the original. In case no values are missing the original array is
returned as that is convenient.</p>
</div>
<div class='tags'>
  <h3>Parameters:</h3>
  <ul class='param'>
    <li>
      <span class='name'>2-item</span>
      <span class='type'>
        (<tt>Array</tt>)
      </span>
      &mdash;
      <span class='desc'>arrays describing the x, y coordinates of the control points.</span>
    </li>
    <li>
      <span class='name'>end</span>
      <span class='type'>
        (<tt>Number</tt>)
      </span>
      &mdash;
      <span class='desc'>x value of the array (maximum)</span>
    </li>
  </ul>
  <h3>Returns:</h3>
  <ul class='return'>
    <li>
      <span class='type'></span>
      (<tt>Array</tt>)
      &mdash;
      <span class='desc'>Array whose index represents every x-value between start and end, and value represents the corresponding y-value.</span>
    </li>
  </ul>
</div>
  </div>
</div>
    </div>
    <div id='footer'>
  Generated on
  Wed Nov 13 2013 09:33:09 GMT-0500 (EST)
  by
  <a href='https://github.com/netzpirat/codo' title='CoffeeScript API documentation generator'>Codo</a>
  v1.7.0
  (Node.js v0.10.21).
  &#10034;
  Press Ctrl-h to see the keyboard shortcuts
  &#10034;
  <a href='http://twitter.com/#!/netzpirat'>@netzpirat</a>
  &#10034;
  <a href='https://mksoft.ch'>mksoft.ch</a>
</div>
  </body>
</html>